﻿using Autofac;
using Loong.AspNetCore.Authentication;
using Loong.AspNetCore.Mvc;
using Loong.Modules;
using Loong.Redis.Threading.Locks;
using Loong.Runtime.Caching.Memory;
using Loong.Threading.Locks;
using Loong.Threading.Locks.Database;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Loong.Web.Api
{
    public class WebApiModule : Module, ILoongModule
    {
        public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
        {
            services.AddControllers(options =>
            {
                options.AddCustomFilters();
            });
            services.AddJwtBearer(configuration);
            services.AddMicrosoftMemoryCache();
            services.AddDatabaseLock(provider =>
            {
                provider.UseMySql();
            });
            //services.AddRedisLock();
        }

        protected override void Load(ContainerBuilder builder)
        {
        }

        public void Initialize()
        {
        }

        public void Shutdown()
        {
        }
    }
}
